/*
void solve(int id,int d0,int v0,int a0){
	if(a0>0){
		if(V<v0){
			car[id].l=d0,car[id].r=L;
		}else{
			int S=ceil(1.0000*(V*V-v0*v0)/2/a0);
			if(S+d0<=L)
				car[id].l=S+d0,car[id].r=L;
			else car[id].l=-1,car[id].r=-1;
		}
	}else if(a0==0){
		if(V<v0)
			car[id].l=d0,car[id].r=L;
		else car[id].l=-1,car[id].r=-1;
	}else {
		if(V<v0){
			int S=1.0000*(V*V-v0*v0)/2/a0;
			car[id].l=d0,car[id].r=min(L,d0+S);
		}else car[id].l=-1,car[id].r=-1;
	}
	return ;
}*/




#include<bits/stdc++.h>
using namespace std;
long long T,n,m,L,V,d[100010],v[100010],p[100010],ans,a[100010];

void solve1(){
	ans=n;
	for(int i=1;i<=n;i++){
		if(d[i]>p[m])ans--;
		else{
			if(V>=v[i])ans--;
		}
	}
	printf("%lld ",ans);
	if(ans!=0)printf("%lld\n",m-1);
	else printf("%lld\n",m);
	return ;
}

void solve2(){
	ans=n;//ans chaosu
	for(int i=1;i<=n;i++){
		if(d[i]>p[m])ans--;
		else {
			long long vv=ceil(sqrt(1.000*v[i]*v[i]+2.000*a[i]*(p[m]-d[i])));
			if(V>=vv)ans--;
		}
	}
	printf("%lld ",ans);
	if(ans!=0)printf("%lld\n",m-1);
	else printf("%lld\n",m);
	return ;
}
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	scanf("%lld",&T);
	while(T--){
		scanf("%lld%lld%lld%lld",&n,&m,&L,&V);
		for(int i=1;i<=n;i++)
			scanf("%lld%lld%lld",&d[i],&v[i],&a[i]);
		for(int i=1;i<=m;i++)
			scanf("%lld",&p[i]);
		if(a[1]==0)solve1();
		if(a[1]>0) solve2();
	}
	return 0;
}
